#include "Stack.h"

void Operator(Stack *op, Stack *number)
{
    int num1 = 0;
    int num2 = 0;
    int sum = 0;
    int oper;
    Pop(op, &oper);
    Pop(number, &num2);
    Pop(number, &num1);
    switch (oper)
    {
    case '*':
        sum = num1 * num2;
        break;
    case '/':
        sum = num1 / num2;
        break;
    case '+':
        sum = num1 + num2;
        break;
    case '-':
        sum = num1 - num2;
        break;
    default:
        break;
    }
    Push(number, sum);
}

int Infix_Expression(char Infix[], int len)
{
    Stack op, number;
    InitSatck(&op, len);
    InitSatck(&number, len);
    Push(&number, 0);
    int i = 0;
    while (i < len)
    {
        if (Infix[i] >= '0' && Infix[i] <= '9')
        {
            int sum = 0;
            while (i < len && Infix[i] >= '0' && Infix[i] <= '9')
            {
                sum += sum * 10 + (Infix[i] - '0');
                i++;
            }
            if (i == len)
            {
                Push(&number, sum);
                break;
            }
            else
            {
                Push(&number, sum);
                i--;
            }
        }

        else if (Empty(&op) || GetTop(&op) == '(')
        {
            Push(&op, Infix[i]);
        }
        else if (Infix[i] == ')')
        {
            while (1)
            {
                Operator(&op, &number);
                if (GetTop(&op) == '(')
                    break;
            }
            DataType tmp = 0;
            Pop(&op, &tmp);
        }
        else if (Infix[i] == '+' || Infix[i] == '-')
        {
            while (1)
            {
                if (Empty(&op) || GetTop(&op) == '(')
                    break;
                Operator(&op, &number);
            }
            Push(&op, Infix[i]);
        }
        else if (Infix[i] == '*' || Infix[i] == '/')
        {
            while (1)
            {
                if (Empty(&op) || (GetTop(&op) != '*' && GetTop(&op) != '/'))
                    break;
                Operator(&op, &number);
            }
            Push(&op, Infix[i]);
        }
        i++;
    }
    while (!Empty(&op))
    {
        Operator(&op, &number);
    }
    return GetTop(&number);
}
int main()
{
    char Infix[128];
    scanf("%s", Infix);
    int len = strlen(Infix);
    int res = Infix_Expression(Infix, len);
    printf("%d\n", res);
    return 0;
}